﻿using System;

namespace OhioState.Graphics.OpenGL
{
    public class DepthBufferHandler : OpenGLObject, IDepthBuffer, IOpenGLResource, IDisposable
    {
        public int Width { get; private set; }
        public int Height { get; private set; }
        public bool StencilSupport { get; private set; }

        public DepthBufferHandler(DepthBufferProxy depthBufferProxy) : base(depthBufferProxy)
        {
            this.Width = depthBufferProxy.Width;
            this.Height = depthBufferProxy.Height;
            this.StencilSupport = depthBufferProxy.StencilSupport;
            realDepthBuffer = new DepthBufferGL(Width, Height, StencilSupport);
        }

        #region IHardwareResource<uint> Members
        public uint GUID
        {
            get
            {
                return (realDepthBuffer as IOpenGLResource).GUID;
            }
        }
        #endregion

        #region IDisposable Members
        public override void Dispose()
        {
            IDisposable realObject = realDepthBuffer as IDisposable;
            if( realObject != null)
                realObject.Dispose();
            base.Dispose();
            GC.SuppressFinalize(this);
        }
        #endregion

        private IDepthBuffer realDepthBuffer;
    }
}
